<template>
  <div class="check-dept">
    <div class="dept-content">
      <Tree :data="treeData" ref="deptTree"></Tree>
    </div>
    <div class="modal-btn">
      <Button @click="closeModal">取消</Button>
      <Button type="primary" @click="sureDept">确定</Button>
    </div>
  </div>
</template>

<script>
import * as API from "@/api/sys-dept";


export default {
  name: "check-dept",
  props:{
    isSingle:{
      type:Boolean,
      default:false
    },
    currentId:{
      type:String,
      default:""
    },
    checkedArr:{
      type:Array,
      default(){
        return []
      }
    }
  },
  data(){
    return{
      treeData:[],
    }
  },
  computed:{
  },
  methods:{
    //关闭弹窗
    closeModal(){
      this.$emit("close-modal")
    },

    //关闭弹窗
    sureDept(){
      this.$emit("sure-back",this.$refs.deptTree.getSelectedNodes())
    },

    //获取组织架构树
    getTreeData(){
      API.getExceptChildTree({id:this.currentId}).then(res=>{
        if (res.code ==='0'){
          this.treeData = res.data
        }
      })
    }
    },
  created() {
    this.getTreeData()
  }
}
</script>

<style lang="less" scoped>
.check-dept{
 .dept-content{
   height: 50vh;
 }
}
</style>
